package com.wquick.base.utils.permissionFlow

/**
 * State model of a permission
 *
 * @property permission Name of a permission
 * @property isGranted State of a permission whether it's granted or not
 * @property isRationaleRequired Whether to show rationale for a permission or not.
 */
data class PermissionState(
    val permission: String,
    val isGranted: Boolean,
    val isRationaleRequired: Boolean?,
)

/**
 * State model for multiple permissions
 *
 * @property permissions List of state of multiple permissions
 */
data class MultiplePermissionState(val permissions: List<PermissionState>) {
    /** Returns true if all permissions are granted by user */
    val allGranted by lazy { permissions.all { it.isGranted } }

    /** List of permissions which are granted by user */
    val grantedPermissions by lazy { permissions.filter { it.isGranted }.map { it.permission } }

    /** List of permissions which are denied / not granted by user */
    val deniedPermissions by lazy { permissions.filter { !it.isGranted }.map { it.permission } }

    /** List of permissions which are required to show rationale */
    val permissionsRequiringRationale by lazy {
        permissions.filter { it.isRationaleRequired == true }.map { it.permission }
    }
}